Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Int32 random method generation with passed range into it #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

azakordonets
Copy link

Upper bond cannot be less the lower bond. Added unit tests as well.

@thellimist
Copy link
Owner

thellimist commented Jan 7, 2018

I think this is a Swift 3 change. Could you add the necessary checks and tests as well?

https://github.com/azakordonets/SwiftRandom/blob/026db916dc668c5bd9ca978b1252d322820389f3/SwiftRandom/Randoms.swift#L21-L27

Thanks

@azakordonets
Copy link
Author

Done

return random(range.lowerBound, range.upperBound)
#else
return random(range.lowerBound, range.upperBound - 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this is correct. Based on that, the parameters are reversed and -1 should go to swift 3 >=. I haven't tested it so my assumption might be wrong. I'd appreciate if you can confirm both Int and Int32 works.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants